// pages/monitor/index.js
const $api = require("../../api/monitor").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerSrc:"https://img01.yzcdn.cn/vant/apple-1.jpg",
    lists:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.getCameraList()
  },
  getCameraList(){
    var t = this,
    data = {
      member_id:wx.getStorageSync('memberinfo').member_id,
      child_id:"",
      member_type:1,
      institution_id:wx.getStorageSync('TeacherClassinfo').institution_id,
      class_id:wx.getStorageSync('TeacherClassinfo').class_id,
      grade_id:wx.getStorageSync('TeacherClassinfo').grade_id,
    }
    $api.getCameraList(data).then(res=>{
      console.log(res)
      t.setData({
        lists:res.data
      })
    })
  },
  gotomonitorlive(e){
    var t = this,
    data = {
      member_id:wx.getStorageSync('memberinfo').member_id,
      child_id:0,
      member_type:1,
      institution_id:wx.getStorageSync('TeacherClassinfo').institution_id,
    }
    $api.getCameraOpen(data).then(res=>{
      wx.navigateTo({
        url: '/pages/monitorlive/index?url=' + encodeURIComponent(e.currentTarget.dataset.url),
      })
    })
    console.log(e)
    
  }
})